<?php

use yii\helpers\Html;
use common\models\GoodsManager;
use kartik\grid\GridView;
use kartik\dynagrid\DynaGrid;

/* @var $this yii\web\View */
/* @var $searchModel common\models\GoodsManagerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '物品管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header') ?>
<?= $this->title ?>
<?php $this->endBlock() ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <div class="box box-primary">
        <div class="box-body">
        <?=
        DynaGrid::widget([
            'columns' => [
                'id',
                [
                    'attribute'=>'goods_name',
                    'value'=>'goods.name',
                    'label'=>'物品名称'
                    
                ],
                'borrower',
                [
                    'attribute'=>'created_at',
                    'filterType' => GridView::FILTER_DATE,
                    //             'filter' =>GoodsManager::STATUS,
                    'filterWidgetOptions' => [
                        'pluginOptions' => [
                            'allowClear' => true,
                            'format' => 'yyyy-mm-dd',
                            'todayHighlight' => true
                        ],
                    ],
                    'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                //                     'long',
                [
                    'attribute'=>'status',
                    'value'=>function($model){
                    return GoodsManager::STATUS[$model->status];
                },
                'filterType' => GridView::FILTER_SELECT2,
                'filter' =>GoodsManager::STATUS,
                'filterWidgetOptions' => [
                    'pluginOptions' => ['allowClear' => true],
                ],
                'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                [
                    'attribute'=>'return_time',
                    'filterType' => GridView::FILTER_DATE,
                    //             'filter' =>GoodsManager::STATUS,
                    'filterWidgetOptions' => [
                        'pluginOptions' => [
                            'allowClear' => true,
                            'format' => 'yyyy-mm-dd',
                            'todayHighlight' => true
                        ],
                    ],
                    'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                [
                    'attribute'=>'real_return_time',
                    'filterType' => GridView::FILTER_DATE,
                    'filterWidgetOptions' => [
                        'pluginOptions' => [
                            'allowClear' => true,
                            'format' => 'yyyy-mm-dd',
                            'todayHighlight' => true
                        ],
                    ],
                    'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                ['class' => 'kartik\grid\ActionColumn','dropdown'=>true,'dropdownButton'=>['label'=>'工具箱','class'=>'btn btn-default'],  'dropdownOptions' => ['class' => 'float-right'],'headerOptions' => ['class' => 'kartik-sheet-style']],
            ],
            'storage'=>DynaGrid::TYPE_COOKIE,
            'theme'=>'panel-danger',
            'gridOptions'=>[
                'dataProvider'=>$dataProvider,
                'filterModel'=>$searchModel,
                'panel'=>[
                    'heading'=>false,
                    'type'=>'success',
                    'before'=>Html::a('<i class="glyphicon glyphicon-plus"></i>物品外借', ['create'], ['class' => 'btn btn-success']),
                ],
            ],
            'options'=>['id'=>'dynagrid-1'] // a unique identifier is important
        ]);
        ?>
        </div>
    </div>
    